1. Field of the Invention
This invention relates to a programmable controller and particularly to a method of debugging a sequence program.
2. Description of the Backqround Art
A programmable controller (hereinafter referred to as a "PC") is employed to control an object by means of a computer program. In practice, many PCs are used to control a wide variety of devices, machines and actuators in a broad spectrum of environments, e.g. processing plants, manufacturing facilities and the like.
FIG. 6 is a hardware configuration diagram of a conventional PC 10, wherein a CPU 11 is connected by a bus 18 to an OS 12 defining the operation of the CPU 11. A sequence program memory 13, which allows a user to store a user-written sequence program (hereinafter referred to as the "sequence program") for subsequent access, also is connected to the bus 18. A device memory 14 serves as an internal memory which allows the user to transfer data, as required. The user writes a sequence program by means of an external device 16 for input into the sequence program memory 13 via a communication interface 15. The external device 16, which allows the sequence program to be created, also permits data from the device memory 14 to be monitored and displayed. The monitoring capability is not illustrated but, as would be understood by one of ordinary skill, a monitor can indicate changes that occur as a result of a sequence program executed in accordance with a program running method. From external device 16, a full program run or a partial run command for the sequence program can be transmitted to the CPU 11.
A "partial run" of the sequence program is conducted when the sequence program is run instruction-by-instruction at particular instruction steps of the sequence program, is run up to a specified instruction step, or is run until it reaches a specified instruction step a specified number of times. Generally, a partial run is employed when debugging the sequence program without connecting the PC 10 to an object to be controlled (not illustrated) after the user has created the sequence program. The partial run permits efficient debugging since only the portions of a program that are of interest need be executed for test purposes. During the run, the program may operate to access or control any of several external devices D.sub.x, e.g. disk drives, modems etc. interfaced into the PC system, each being identified by a unique number "x".
FIG. 7 shows an example of a sequence program segment in the form of a ladder diagram and is useful in illustrating partial run of a sequence program. The sequence program segment shown in FIG. 7 is operative to run until the identifier X for the selected one of the several external devices D.sub.x changes to "9". Specifically, parameter values of X=9 are set at each of program steps 52, 54 and 56, which are followed by respective condition instructions 58. When run, the program permits an identification of the program step and scan at which the sequence program is stopped by means of the external device 16. For this purpose, a "scan" will be understood as the activity beginning with the execution of an instruction step 0 and proceeding to the occurrence of an END instruction that is followed by another instruction step 0 in the sequence program.
FIG. 8 is a flowchart illustrating a sequence for running the sequence program shown in FIG. 7.
Operation will now be described with reference to FIGS. 7 and 8 where X identifies a external device D.sub.x, Y identifies the number of scans and Z identifies a current program step number. In FIG. 8, the partial run of the sequence program is started at sequence step 100. Data X, identifying the external device D.sub.x, is changed at sequence step 101, i.e. X=1 is obtained by executing X=X+1 (initial value X=0) at program step 51 in FIG. 7. Then, whether X=9 or not is judged at sequence step 102, i.e. program step 52 in FIG. 7 is executed. If X=9, the operation proceeds to sequence step 108 where the current program step number is stored in an external storage device D.sub.z, i.e. program step 58 in FIG. 7 is executed. However, since X=1 in this case, sequence step 103, i.e. program step 53 in FIG. 7, is executed and X=3 is obtained according to X=X+2. Then, whether X=9 or not is judged again at sequence step 104, i.e. program step 54 in FIG. 7 is executed. Since X is not 9, sequence step 105, i.e. program step 55 in FIG. 7, is executed and X=6 is obtained according to X=X+3. Then, whether X=9 or not is judged again at sequence step 106, i.e. program step 56 in FIG. 7 is executed. Since X is not 9, sequence step 107, i.e. program step 57 in FIG. 7, is executed and "1" is added to an external storage device D.sub.y which counts the number of scans. If it is assumed that the external device D.sub.y already stores an initial value of Y=1, indicating the conduct of a first scan, Y=2 is obtained according to Y=Y+1. In FIG. 7, "INC Y" indicates the addition of 1 to the device D.sub.y, i.e. execution of Y=Y+1, and "JMP P1" indicates an instruction which causes a jump to instruction step P1, i.e. an END instruction step 60.
The operation then executes the END processing at sequence step 110, i.e. program step 60 in FIG. 7, returns to the instruction step 0, i.e. sequence step 101, thereby completing a "scan" sequence, and repeats the processing. As a result of the first scan sequence, for the second scan, the value of the device D.sub.z changes to X=7 according to X=X+1 at the sequence step 101, i.e. the program step 51 in FIG. 7. X will become equal to 9 according to X=X+2 at sequence step 103, i.e. upon execution of program step 53 in FIG. 7. Therefore, X=9 is established at sequence step 104, i.e. when at program step 54 in FIG. 7. As a result, a program step number, i.e. Z=2 in this case, is stored in device D.sub.z at sequence step 108, i.e. program step 58 in FIG. 7, and the operation jumps to instruction step P0.
Clearly, the operation is only caused to jump to instruction step P0 when the device identifier value X changes to "9". Thus, the setting of a "break point", i.e. a position to stop the sequence program, at instruction step P0 in advance allows the number of stop scans (Y) and a stop step (Z) to be identified. The device D.sub.y, which stores the number of scans Y, and device D.sub.z, which stores the stop step number Z at which the execution of the sequence program is to be stopped, can be used to control other operations. An NOP program step 59 in FIG. 7 indicates that instruction step P0 is a no-operation instruction and does not have any influence on the program control. JMP P1 in program step 57 causes a jump to instruction step P1, the END instruction.
However, when it is desired to change device data, the partial run may be performed only after adding (or changing) corresponding relative program steps. Specifically, it is necessary to add the program steps 52 and 58, the program steps 54 and 58, and the program steps 56 and 58 in correspondence with the program steps 51, 53 and 55 shown in FIG. 7, respectively. Therefore, the sequence program must be increased by six program steps and, as a result, becomes complicated and inefficient.
Also in this conventional technique, if it must be determined whether X or some other parameter has taken a particular value, an interrogation of the system for that criterion was required at each step. Such determination would have been made by checking whether a particular address has particular data values, thereby requiring extensive processing time.